/*
 * @Author: lizilong 94648929@qq.com
 * @Date: 2022-11-12 20:30:02
 * @LastEditors: lizilong 94648929@qq.com
 * @LastEditTime: 2022-11-12 20:31:07
 * @FilePath: \sofast-admin\src\locals\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createI18n } from 'vue-i18n';
import zh from './language/zh';
import en from './language/en';

const messages = {
  en,
  zh,
};

// 这是获取浏览器的语言
const language = (navigator.language || 'en').toLocaleLowerCase();
// 创建
const i18n = createI18n({
  // 首先从缓存里拿，没有的话就用浏览器语言，
  locale: localStorage.getItem('lang') || language.split('-')[0] || 'en',
  fallbackLocale: 'en', // 设置备用语言
  messages,
});

export default i18n;
